<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="java.util.List"%>
<%@page import="cn._2dland.bots.Utils"%>
<%@page import="cn._2dland.bots.jdo.AccountManager"%>
<%@page import="cn._2dland.bots.jdo.models.Account"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="/style/common.css">
<link rel="stylesheet" type="text/css" href="/style/style.css">
<link rel="stylesheet" type="text/css" href="/style/dialog.css">
<script language="javascript" src="/js/jquery-1.4.2.min.js"></script>
<script language="javascript" src="/js/dialog.js"></script>
<script language="javascript">
function new_account(){
	Dialog.showURL('添加帐户',true,'account.jsp?action=new',200,100,true);
	return false;
}
function edit_account(acctId){
	Dialog.showURL('修改帐户',true,'account.jsp?action=edit&acctid='+acctId,200,120,true);
	return false;
}
function delete_account(acctId){
	if(window.prompt('是否删除该帐户？')) {
		$.post('/manager',{action:3,acctid:acctId},handler);
	}
	return false;
}
function handler(data){
	alert(data);
}
</script>
<title>机器人帐户列表</title>
</head>
<body>
<div><a href="#" onclick="return new_account();">添加帐户</a></div>
<div><table cellpadding="0" cellspacing="0" border="0" class="account-list">
<tr>
	<th>帐户</th>
	<th>密码</th>
	<th>最后执行时间</th>
	<th>状态</th>
	<th>操作</th>
</tr>
<%
AccountManager am = new AccountManager();
try {
	List<Account> accts = am.getAccounts();
	for(int i=0; i<accts.size(); i++) {
		Account a = accts.get(i);
		String s = Utils.getStatusName(a.getStatus());
		String t = Utils.formatTime(a.getLastTime());
%>
<tr>
	<td><%=a.getUsername()%></td>
	<td><%=a.getPassword()%></td>
	<td><%=t%></td>
	<td><%=s%></td>
	<td><a href="javascript:void(0);" onclick="return edit_account(<%=a.getID()%>);">修改</a> 删除</td>
</tr>
<%
	}
}
finally {
	am.close();
}
%>
</table></div>
</div>
</body>
</html>